package pages;
import core.TestBase;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import utils.Log4Test;

import static org.testng.AssertJUnit.assertFalse;


public class ComparePage extends TestBase {


    public void waitForPageLoaded(WebDriver driver)
    {
        ExpectedCondition<Boolean> expectation = new
                ExpectedCondition<Boolean>() {
                    public Boolean apply(WebDriver driver) {
                        return ((JavascriptExecutor) driver).executeScript("return document.readyState").equals("complete");
                    }
                };
        try {
            wait.until(expectation);
        } catch (Throwable error) {
            assertFalse("Timeout waiting for Page Load Request to complete.", true);
        }
    }


    // 16. Verify that the page contains "Сравнение товаров"

    public boolean CompareProducts() {
        Log4Test.info("the page contains Сравнение товаров");
        return webDriver.getPageSource().contains("Сравнение товаров");
    }

    //  17. Verify that the page "Добавить модель should contain Apple MacBook Pro Retina 15" (Z0PU002JE) Официальная гарантия! and
    //   Apple MacBook Pro Retina 15" (ME294UA/A) Официальная гарантия!


    public String AddModelContainsProducts(){
        Log4Test.info("The page contains Apple MacBook Pro Retina 15\" (Z0PU002JE), Apple MacBook Pro Retina 15\" (ME294UA/A)");
        return webDriver.getPageSource();

    }

}
